<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>卫生机构收集数据</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
        
        .layui-form-select dl dd.layui-this {
            background-color: #1e9FFF;
        }
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:130px">搜索卫生机构：</label>
            <div class="layui-inline">
                <select name="area" id="area" class="layui-input" lay-search>
                        <option value=""></option>
                       
                </select>
            </div>
            收集日期：
            <div class="layui-inline" style="width:200px">
                <input type="text" class="layui-input" id="datetime" placeholder="请选择日期">
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch"> <i class="layui-icon">&#xe615;</i>查询</button>

        </div>
    </div>

    <table id="demo" lay-filter="test"></table>

    </div>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime', //指定元素
                theme: '#1E9FFF',
                range: true,
                max: 0
            });
        });
        $.ajax({
            url: '../../../Cust/customer',
            dataType: 'json',
            type: 'get',
            success: function(res) {
                $.each(res.data, function(index) {
                    var n = res.data[index].name;
                    var value = res.data[index].id;
                    $("#area").append("<option value='" + value + "'>" + n + "</option>")

                });
                layui.form.render();
            }
        })
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;
            var tableIns = table.render({
                elem: '#demo',
                height: 'full-90',
                //url: '', //数据接口
                data: [],
                cols: [
                    [
                        //表头
                        {
                            field: 'custname',
                            title: '医院名称',
                            width: '20%',
                            align: 'center'
                        }, {
                            field: 'garbage',
                            title: '感染性废物',
                            width: '11%',
                            align: 'center'
                        }, {
                            field: 'lwq',
                            title: '损伤性废物',
                            width: '11%',
                            align: 'center'
                        }, {
                            field: 'guil',
                            title: '病理性废物',
                            width: '11%',
                            align: 'center'
                        }, {
                            field: 'qt',
                            title: '药物性废物',
                            width: '11%',
                            align: 'center'
                        }, {
                            title: '化学性废物',
                            width: '11%',
                            align: 'center',
                            templet: function(d) {
                                return 0;
                            }
                        }, {
                            field: 'totalcollect',
                            title: '总箱数',
                            width: '11%',
                            templet: function(d) {
                                return parseInt(d.totalcollect);
                            },
                            align: 'center'
                        }, {
                            field: 'totalweight',
                            title: '总重量（吨）',
                            width: '11%',
                            templet: function(d) {
                                return parseFloat(d.totalweight).toFixed(2);
                            },
                            align: 'center'
                        }
                    ]
                ],
                skin: 'row' //表格风格
                    ,
                even: true
            });
            $("#serch").on('click', function() {
                tableIns.reload({
                    url: '../../../Customer/customerCollect',
                    where: {
                        custid: $("#area option:selected").val(),
                        startdate: $("#datetime").val().split(" - ")[0],
                        enddate: $("#datetime").val().split(" - ")[1]
                    } //设定异步数据接口的额外参数

                });
                $("table tr").css({
                    "background": "#1E9FFF",
                    "color": "white"
                });
            });


            $("table tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });
        });
    </script>
</body>

</html>